﻿using System;
using System.Collections.Generic;
using System.Text;
using Torch.WL.Business.Interface;
using Torch.FrameWork.Utility;
using Torch.WL.Business.CleanChina;
using Torch.WL.Entity.CleanChina;

namespace Torch.WL.Business
{
    public class AdvertiseProvider : BaseProvider<AdvertiseProvider.RequestDataInfo>, IDataProvider
    {
        public AdvertiseProvider(string _jsonInfo)
            : base(_jsonInfo)
        {

        }

        public IMessageInfo Do()
        {
            IMessageInfo message = new MessageInfo();
            message.code = (int)MessageCodeType.Success;
            message.message = Utils.GetEnumDescription(MessageCodeType.Success);
            message.data = ProcessResponseData();

            //throw new Exception("xxxxxxxxx");
            return message;
            
        }

        private ResponseDataInfo ProcessResponseData()
        {
            //use postdata.data to process responseData
            ResponseDataInfo responseData = new ResponseDataInfo();
            TbAdvertiseEntity entity = TbAdvertiseManager.Instance().GetCurrentAdvertistByCache();
            if (entity == null)
                return null;
            else
                responseData.img = ConfigHelper.GetConfigString("WebsiteImageUrl") + entity.adv_img;

            return responseData;         
        }

        public class RequestDataInfo 
        {          
        }

        public class ResponseDataInfo
        {
            public string img { get; set; }
        }


    }
}
